package com.tyrone.gateway.transport.config;

import com.tyrone.gateway.common.ThreadContextUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.FullHttpResponse;

import java.util.concurrent.CompletableFuture;

/**
 * @author yelong.xie
 * @date 2024/5/8 23:41
 */
public class DispatchClientCallResponseHandler extends SimpleChannelInboundHandler<FullHttpResponse> {
    private final CompletableFuture<FullHttpResponse> future;

    public DispatchClientCallResponseHandler(CompletableFuture<FullHttpResponse> future) {
        this.future = future;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, FullHttpResponse fullHttpResponse) throws Exception {
        future.complete(fullHttpResponse);
    }
}
